package com.example.tutormanagement.controller;

import com.example.tutormanagement.pojo.Result;
import com.example.tutormanagement.pojo.Salary;
import com.example.tutormanagement.pojo.Schedule;
import com.example.tutormanagement.service.SalaryService;
import com.example.tutormanagement.service.ScheduleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * &#064;Date: 23/06/15-14:38
 * &#064;Description:
 */
@RestController
@RequestMapping("/schedule")
public class ScheduleController {

    @Autowired
    private ScheduleService scheduleService;

    // get-all-data
    @GetMapping
    public Result list() {
        List<Schedule> schedules = scheduleService.list();
        return Result.success(schedules);
    }

    @GetMapping("/{id}")
    public Result select(@PathVariable String id) {
        Schedule schedule = scheduleService.select(id);
        return Result.success(schedule);
    }

    // update-data
    @PutMapping("/{id}")
    public Result update(@RequestBody Schedule schedule, @PathVariable String id) {
        scheduleService.update(schedule, id);
        return Result.success();
    }
}
